#include "fifo.hpp"
#include "log.hpp"

int main()
{
    Log log;
    log.Enable(Classfile);

    // 命名管道由服务端创建，那么客户端就直接打开命名管道文件即可
    int fd = open(FIFO_FILE, O_WRONLY);
    if(fd < 0)
    {
        log(Fatal, "err string %s, err code: %d", strerror(errno), errno);
        perror("open");
        exit(OPEN_FIFE_FRR);
    }

    cout << "client open fifo done" << endl;
    log(Info, "err string %s, err code: %d", strerror(errno), errno);

    string line;
    while(true)
    {
        cout << "@Please Enter:";
        getline(cin,line);
        write(fd,line.c_str(), line.size());
    }

    close(fd);

    return 0;
}